home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / os2 / ext2_200.zip / EXT2_SRC.ZIP / 32BITS / EXT2-OS2 / VOLUME.C < prev   
C/C++ Source or Header  |  1996-09-22  |  5KB  |  170 lines

  1. //
  2. // $Header: D:/32bits/ext2-os2/RCS/volume.c,v 1.1 1996/09/22 23:14:04 Willm Exp Willm $
  3. //
  4.  
  5. // Linux ext2 file system driver for OS/2 2.x and WARP - Allows OS/2 to
  6. // access your Linux ext2fs partitions as normal drive letters.
  7. // Copyright (C) 1995, 1996 Matthieu WILLM
  8. //
  9. // This program is free software; you can redistribute it and/or modify
  10. // it under the terms of the GNU General Public License as published by
  11. // the Free Software Foundation; either version 2 of the License, or
  12. // (at your option) any later version.
  13. //
  14. // This program is distributed in the hope that it will be useful,
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. // GNU General Public License for more details.
  18. //
  19. // You should have received a copy of the GNU General Public License
  20. // along with this program; if not, write to the Free Software
  21. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  
  23. //
  24. // Will be eventually moved to ext2/super.c, and openvolume will be split into
  25. // ext2_read_super() and its calling VFS routine
  26. //
  27. #ifdef __IBMC__
  28. #pragma strings(readonly)
  29. #endif
  30.  
  31.  
  32. #define INCL_DOSERRORS
  33. #define INCL_NOPMAPI
  34. #include <os2.h>
  35. #include <string.h>
  36.  
  37. #include <os2/errors.h>
  38.  
  39.  
  40. #include <os2/types.h>
  41. #include <os2/fsh32.h>
  42. #include <os2/devhlp32.h>
  43. #include <os2/StackToFlat.h>
  44. #include <os2/os2proto.h>
  45. #include <os2/os2misc.h>
  46.  
  47.  
  48. #include <linux/fs.h>
  49. #include <linux/ext2_fs.h>
  50. #include <linux/fs_proto.h>
  51. #include <linux/ext2_proto.h>
  52. #include <linux/sched.h>
  53.  
  54. #include <os2/log.h>         /* Prototypes des fonctions de log.c                      */
  55. #include <os2/volume.h>      /* Prototypes des fonctions de volume.c                   */
  56. #include <os2/minifsd.h>
  57.  
  58.  
  59.  
  60.  
  61. //
  62. // Called by MFS_TERM to do ring 0 initializations and inherit files and volumes
  63. // opened by the minifsd.
  64. //
  65. int FS32CALLBACK inherit_minifsd_data(PTR16 __mfs_data) {
  66.     struct super_block *sb;
  67.     int db_count;
  68.     int i, j;
  69.     int rc;
  70.     struct minifsd_to_fsd_data *mfs_data;
  71.  
  72.     if ((rc = DevHlp32_VirtToLin(__mfs_data, __StackToFlat(&mfs_data))) != NO_ERROR)
  73.     return rc;
  74.  
  75.     /*
  76.      * Ring 0 FSD initializations
  77.      */
  78. //    ring0_ext2_os2_init();
  79.  
  80.     /*
  81.      * Inherits I-nodes used by the mini FSD
  82.      */
  83.     inherit_minifsd_inodes(mfs_data);
  84.  
  85.     /*
  86.      * Inherits open files from the mini FSD
  87.      */
  88.     inherit_minifsd_files(mfs_data);
  89.  
  90.     /*
  91.      * Inherits mounted volumes from the mini FSD
  92.      */
  93. #if 0
  94.     for (i = 0; i < NB_MAX_VOLS; i++) {
  95.         if (mfs_data->volglobdat->listvol[i].status == VOL_STATUS_MOUNTED) {
  96.             sb = mfs_data->volglobdat->listvol[i].sb;
  97.             if (sb) {
  98.                 /*
  99.                  * re-reads the buffer containing the superblock itself
  100.                  */
  101.                 char *tmp = (char *)((char *)(sb->u.ext2_sb.s_es) - (char *)(sb->u.ext2_sb.s_sbh->b_data));
  102.                 sb->u.ext2_sb.s_sbh = bread(sb->s_dev, sb->u.ext2_sb.s_sbh->b_blocknr, sb->s_blocksize);
  103.                 sb->u.ext2_sb.s_es = (struct ext2_super_block *)((unsigned long)tmp + (unsigned long)(sb->u.ext2_sb.s_sbh->b_data));
  104.  
  105.  
  106.                 /*
  107.                  * re-reads the buffers containing group descriptors
  108.                  */
  109.                 db_count = (sb->u.ext2_sb.s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) /
  110.                             EXT2_DESC_PER_BLOCK(sb);
  111.                 for (j = 0; j < db_count; j++) {
  112.                     sb->u.ext2_sb.s_group_desc[j] = bread(sb->s_dev, sb->u.ext2_sb.s_group_desc[j]->b_blocknr,
  113.                                                        sb->s_blocksize);
  114.                 }
  115.  
  116.                 /*
  117.                  * updates the superblock operations pointer
  118.                  */
  119.                 sb->s_op = &ext2_sops;
  120.  
  121.                 /*
  122.                  * updates the volume table
  123.                  */
  124.                 volglobdat.listvol[i].sb     = sb;
  125.                 volglobdat.listvol[i].status = VOL_STATUS_MOUNTED;
  126.                 volglobdat.listvol[i].hVPB   = mfs_data->volglobdat->listvol[i].hVPB;
  127.  
  128.                 /*
  129.                  * remounts in read/write mode if necessary
  130.                  */
  131.                 if (Read_Write) {
  132.                     sb->s_flags &= ~MS_RDONLY;
  133.                     ext2_setup_super (sb, sb->u.ext2_sb.s_es);
  134.                 }
  135.             } else {
  136.                 ext2_os2_panic(0, "MINIFSD volume mounted but sb = 0 !");
  137.             }
  138.         }
  139.     }
  140. #endif
  141.     return NO_ERROR;
  142. }
  143.  
  144. extern struct super_block * FSH32ENTRY __getvolume(PTR16 pvpfsd);
  145.  
  146. struct super_block * getvolume(unsigned short hVPB)
  147. {
  148.     struct super_block *sb;
  149.     int                 rc;
  150.     PTR16               pvpfsi;
  151.     PTR16               pvpfsd;
  152.  
  153.     sb = 0;
  154.     if (hVPB) {
  155.         if ((rc = fsh32_getvolparm(hVPB, __StackToFlat(&pvpfsi), __StackToFlat(&pvpfsd))) == NO_ERROR) {
  156.             sb = __getvolume(pvpfsd);
  157.         } else {
  158.             kernel_printf("getvolume - rc = %d", rc);
  159.         }
  160.     } else {
  161.         /*
  162.          * This should NEVER occur
  163.          */
  164.         kernel_printf("getvolume called with hVPB = 0");
  165.     }
  166.     return sb;
  167. }
  168.  
  169.  
  170.